import javax.xml.bind.annotation.XmlType;
import java.util.Arrays;

public class MyStack {
    int[] elem;
    int usedSize;
    public final static int DEFAULT_SIZE = 10;

    public MyStack(int[] elem) {
        this.elem = new int[DEFAULT_SIZE];
    }

    public void push(int key) {
        if (usedSize > DEFAULT_SIZE) {
            this.elem = Arrays.copyOf(elem,usedSize*2);
        }
        elem[usedSize] = key;
        usedSize++;
    }
    public int pop() {
        int ret = peek();
        usedSize--;
        return ret;
    }
    public int peek() {
        if ( !isEmpty() ) {
            return elem[usedSize-1];
        }else {
            return -1;
        }
    }
    public boolean isEmpty() {
        return usedSize == 0;
    }
    public int getUsedSize() {
        return usedSize;
    }

}
